import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { Observer } from 'rxjs/Observer';
import { IContext, IPersist } from '../model/context.interface';
import { Type, InjectionToken } from "@angular/core";
import { PersitContext } from "../model/context";

export interface IContextBroker {
    registerProvider(context: IContext): void;
    registerObservableProvider<T extends IContext>(contextClass: string, contextProvider: Observable<T>): Subscription;
    registerListener<T extends IContext>(contextClass: string, contextObserver: Observer<T>): Subscription;
    registerContextListner<T extends IContext>(contextClass: string): Observable<T>;
    cancelSubscription(subscription: Subscription,requestId?: string): void;
    getPersitContext?<T extends IPersist>(contextClass: string):Observable<T>;
}

export const ICONTEXT_BROKER_TOKEN: InjectionToken<string> = new InjectionToken('ICONTEXT_BROKER_TOKEN');
export const CONTEXT_BROKER_LOGGER: InjectionToken<string> = new InjectionToken('CONTEXT_BROKER_LOGGER');